<template>
  <div>
    <!-- <h3>注册页</h3> -->
    <div>
      <input type="text" placeholder="请输入手机号" v-model="user.phone" />
    </div>
    <div>
      <input type="text" placeholder="请输入昵称" v-model="user.nickname" />
    </div>
    <div>
      <input type="text" placeholder="请输入密码" v-model="user.password" />
    </div>
    <button @click="register">注册</button>
  </div>
</template>

<script>
import { reqRegister } from '../../http/http';
export default {
  data() {
    return {
      // 初始化数据
      user: {
        phone: "",
        nickname: "",
        password: "",
      },
    };
  },
  methods: {
    register() {
      reqRegister(this.user).then((res) => {
        console.log(res);
        if (res.data.code == 200) {
          // 成功
          alert(res.data.msg);
          this.$router.push("/login");
        } else {
          //失败
          alert(res.data.msg);
        }
      });
    },
  },
};
</script>

<style>
</style>